<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="90px">
      <el-form-item label="所属场站" prop="stationName">
        <el-input
          v-model="queryParams.stationName"
          placeholder="请输入所属场站"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="经营户名称" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入经营户名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!--<el-col :span="1.5" v-if="station_btn">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['ledger:account:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5" v-if="station_btn">
        <el-button
          type="info"
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['ledger:account:import']"
        >导入</el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="accountList" :max-height="tableHeight"   @selection-change="handleSelectionChange">
      <el-table-column label="名称" align="left" prop="companyName" />
      <el-table-column label="营业执照号" align="center" prop="businessLicenseNo" />
      <el-table-column label="法人" align="center" prop="legalPerson" width="80px" />
      <el-table-column label="联系电话" align="center" prop="telephone" width="120px"/>
      <el-table-column label="门牌号" align="center" prop="houseNumber" width="80px" />
      <el-table-column label="入住日期" align="center" prop="enteringDate" width="180">
        <template slot-scope="scope">
          <span v-if="scope.row.enteringDate != null">{{ scope.row.enteringDate | dateString('YYYY-MM-DD') }}</span>
          <span v-if="scope.row.enteringDate == null">无</span>
        </template>
      </el-table-column>
      <el-table-column label="叉车数" align="center" prop="forkliftNum" width="80px"/>
      <el-table-column label="叉车操作员(人数)" align="center" prop="forkliftOperatorNum" width="140"/>
      <el-table-column label="所属场站" align="left" prop="stationName" width="300" v-if="!station_btn"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-knife-fork"
            @click="handleForkliftView(scope.row)"
          >叉车</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-s-custom"
            @click="handleWorkerView(scope.row)"
          >人员</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-help"
            @click="handleEquipmentView(scope.row)"
          >消防设备</el-button>
          <!--<el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['ledger:account:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['ledger:account:remove']"
          >删除</el-button>-->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改经营户台账对话框 -->
    <el-dialog :title="title" :visible.sync="open"  width="50%">
      <el-form ref="form" :model="form" :rules="rules" label-width="200px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="名称" prop="companyName">
              <el-input v-model="form.companyName" placeholder="请输入名称" maxlength="30"  show-word-limit/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="营业执照号" prop="businessLicenseNo">
              <el-input v-model="form.businessLicenseNo" placeholder="请输入营业执照号" maxlength="30"  show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法人" prop="legalPerson">
              <el-input v-model="form.legalPerson" placeholder="请输入法人" maxlength="20"  show-word-limit/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="telephone">
              <el-input v-model="form.telephone" placeholder="请输入联系电话" maxlength="20"  show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="门牌号" prop="houseNumber">
              <el-input v-model="form.houseNumber" placeholder="请输入门牌号" maxlength="20"  show-word-limit/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库房" prop="storageRoom">
              <el-input v-model="form.storageRoom" placeholder="请输入库房" maxlength="20"  show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="现有人数" prop="nowNumber">
              <el-input-number v-model="form.nowNumber" placeholder="请输入现有人数" style="width: 100%" controls-position="right" :min="0" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="入住日期" prop="enteringDate">
              <el-date-picker clearable size="small" style="width: 100%"
                              v-model="form.enteringDate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="选择入住日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
<!--        <el-row>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="籍贯" prop="nativePlace">-->
<!--              <el-input v-model="form.nativePlace" placeholder="请输入籍贯" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="联系电话" prop="telephone">-->
<!--              <el-input v-model="form.telephone" placeholder="请输入联系电话" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->
        <el-row>
          <el-col :span="24">
            <el-form-item label="经营范围" prop="businessScope">
              <el-input v-model="form.businessScope" placeholder="请输入经营范围" maxlength="30"  show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="营业执照注册地址" prop="registeredAddressOfBusinessLicense">
              <el-input v-model="form.registeredAddressOfBusinessLicense"   placeholder="请输入营业执照注册地址" maxlength="50"  show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="实际经营地址" prop="actualBusinessAddress">
              <el-input v-model="form.actualBusinessAddress"   placeholder="请输入实际经营地址" maxlength="50"  show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否有运输经营许可证" prop="isBusinessLicensePhoto">
              <el-radio-group v-model="form.isTransportationBusinessLicensePhoto">
                <el-radio
                  v-for="dict in dictList"
                  :key="dict.dictValue"
                  :label="dict.dictValue"
                >{{dict.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="道路运输经营许可证号" prop="roadTransportBusinessLicenseNo">
              <el-input v-model="form.roadTransportBusinessLicenseNo" placeholder="请输入道路运输经营许可证号" maxlength="30"  show-word-limit/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="营运车辆数" prop="numberOfOperatingVehicles">
              <el-input-number v-model="form.numberOfOperatingVehicles" style="width: 100%" placeholder="请输入营运车辆数" controls-position="right" :min="0"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="道路运输经营许可证注册地址" prop="registeredAddressOfRoadTransportBusinessLicense">
              <el-input v-model="form.registeredAddressOfRoadTransportBusinessLicense"  placeholder="请输入道路运输经营许可证注册地址" maxlength="50"  show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>

<!--        <el-row>-->
<!--          <el-col :span="24">-->
<!--            <el-form-item label="注册地址" prop="registeredAddress">-->
<!--              <el-input v-model="form.registeredAddress" type="textarea"  placeholder="请输入注册地址" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->
        <el-row>
          <el-col :span="24">
            <el-form-item label="上传图片">
              <el-upload
                :multiple="true"
                accept=".jpg, .png, .gif, .bmp, .jpeg"
                :headers="uploadImg.headers"
                :action="uploadImg.url"
                :file-list="form.imgList"
                list-type="picture-card"
                :limit="uploadImg.limit"
                :before-upload="beforeImageUpload"
                :on-exceed="exceedFile"
                :on-success="handlePictureSuccess"
                :on-preview="handlePictureCardPreview"
                :on-remove="handleRemove">
                <i class="el-icon-plus"></i>
                <div slot="tip" class="el-upload__tip">只能上传jpg/png/bmp/jpeg文件，且不超过10M</div>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>

    <!-- 详情 -->
    <el-dialog :title="title" :visible.sync="openView"  width="50%">
      <el-form ref="form" :model="form" label-width="200px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="名称:" prop="companyName">{{form.companyName}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="营业执照号:" prop="businessLicenseNo">{{form.businessLicenseNo}}</el-form-item>
          </el-col>
<!--          <el-col :span="12">-->
<!--            <el-form-item label="曾用公司名称:" prop="beforeCompanyName">{{form.beforeCompanyName}}</el-form-item>-->
<!--          </el-col>-->
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="法人:" prop="legalPerson">{{form.legalPerson}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话:" prop="telephone">{{form.telephone}}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="门牌号:" prop="houseNumber">{{form.houseNumber}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库房:" prop="storageRoom">{{form.storageRoom}}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
<!--          <el-col :span="12">-->
<!--            <el-form-item label="企业人数:" prop="companyNumber">{{form.companyNumber}}</el-form-item>-->
<!--          </el-col>-->
          <el-col :span="12">
            <el-form-item label="现有人数:" prop="nowNumber">{{form.nowNumber}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="入住日期:" prop="enteringDate">{{ form.enteringDate | dateString('YYYY-MM-DD') }}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="经营范围:" prop="businessScope">{{form.businessScope}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="营运车辆数:" prop="numberOfOperatingVehicles">{{form.numberOfOperatingVehicles}}</el-form-item>
          </el-col>
        </el-row>
<!--        <el-row>-->
<!--          <el-col :span="12">-->
<!--            <el-form-item label="是否有营业执照:" prop="isBusinessLicensePhoto">{{typeFormat(form.isBusinessLicensePhoto)}}</el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否有运输经营许可证:" prop="isBusinessLicensePhoto">{{typeFormat(form.isTransportationBusinessLicensePhoto)}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="道路运输经营许可证号:" prop="roadTransportBusinessLicenseNo">{{form.roadTransportBusinessLicenseNo}}</el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="营业执照注册地址:" prop="registeredAddressOfBusinessLicense">{{form.registeredAddressOfBusinessLicense}}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="道路运输经营许可证注册地址:" prop="registeredAddressOfRoadTransportBusinessLicense">{{form.registeredAddressOfRoadTransportBusinessLicense}}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="实际经营地址:" prop="actualBusinessAddress">{{form.actualBusinessAddress}}</el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.imgList && form.imgList.length > 0 ">
          <el-col :span="24">
            <el-form-item label="图片:" prop="imgList" class="img">
              <ul>
                <li v-for="img in form.imgList" style="text-align: center;">
                  <el-image :preview-src-list="srcList" :src="img.url" style="width: 100px;height:100px;">
<!--                    <div slot="error" class="image-slot" style="width: 100px;height:100px;border:1px solid #30B08F">-->
<!--                      <i class="el-icon-picture-outline" style="margin-top: 42px"></i>-->
<!--                    </div>-->
                  </el-image>
                </li>
              </ul>
            </el-form-item>
          </el-col>
        </el-row>
<!--        <el-row>-->
<!--          <el-col :span="24">-->
<!--            <el-form-item label="注册地址:" prop="registeredAddress">{{form.registeredAddress}}</el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="openView = false">关 闭</el-button>
      </div>
    </el-dialog>

    <!-- 经营户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的经营户数据
          <a :href='"/profile/files/经营户.xlsx"' style="color:blue;">下载模板</a>
<!--          <el-link type="info" style="color:blue;" @click="importTemplate">下载模板</el-link>-->
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listAccount, getAccount, delAccount, addAccount, updateAccount, exportAccount,importTemplate } from "@/api/ledger/account";
import { getToken } from "@/utils/auth";
export default {
  name: "Account",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 经营户台账表格数据
      accountList: [],
      dictList: [],
      srcList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      openView: false,
      station_btn: false,
      tableHeight: window.innerHeight - 275,
      // 上传图片参数
      uploadImg: {
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/common/upload",
        //  文件个数
        limit: 5
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/ledger/account/importData"
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        stationId: undefined,
        stationName: undefined,
        companyName: undefined,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        companyName: [
          { required: true, message: "企业名称不能为空", trigger: "blur" }
        ],
        businessLicenseNo: [
          { required: true, message: "营业执照号不能为空", trigger: "blur" }
        ],
        legalPerson: [
          { required: true, message: "法人不能为空", trigger: "blur" }
        ],
        telephone: [
          { required: true, message: "联系电话不能为空", trigger: "blur" }
        ],
      },
      dialogImageUrl: '',
      dialogVisible: false
    };
  },
  mounted() {
    const stationId = this.$route.params && this.$route.params.stationId;
    this.queryParams.stationId=stationId;
    const stationName = this.$route.params && this.$route.params.stationName;
    this.queryParams.stationName=stationName;
    this.getList();

    this.dictList = [{"dictValue":"0","dictLabel":"有"},{"dictValue":"1","dictLabel":"无"}]

    const roles = this.$store.getters && this.$store.getters.roles;
    for (let rol of roles){
      if ('station'==rol || 'hs_station'==rol){
        this.station_btn=true;
      }
    }
  },
  methods: {
    /** 查询经营户台账列表 */
    getList() {
      this.loading = true;
      listAccount(this.queryParams).then(response => {
        this.accountList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        stationId: undefined,
        houseNumber: undefined,
        storageRoom: undefined,
        beforeCompanyName: undefined,
        companyName: undefined,
        companyNumber: undefined,
        nowNumber: undefined,
        legalPerson: undefined,
        telephone: undefined,
        legalPersonIdcard: undefined,
        nativePlace: undefined,
        businessScope: undefined,
        isBusinessLicensePhoto: undefined,
        businessLicenseNo: undefined,
        registeredAddressOfBusinessLicense: undefined,
        isTransportationBusinessLicensePhoto: undefined,
        roadTransportBusinessLicenseNo: undefined,
        registeredAddressOfRoadTransportBusinessLicense: undefined,
        numberOfOperatingVehicles: undefined,
        actualBusinessAddress: undefined,
        registeredAddress: undefined,
        enteringDate: undefined,
        delFlag: undefined,
        createTime: undefined,
        createId: undefined,
        updateTime: undefined,
        updateId: undefined,
        remark: undefined,
        imgList: [],
        imgs:[],
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加经营户";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getAccount(id).then(response => {
        this.form = response.data;
        const imgs = [];
        this.form.imgList.map(function (item) {
          imgs.push(item.url);
        });
        this.form.imgs = imgs;
        this.open = true;
        this.title = "修改经营户";
      });
    },
    /** 详情 **/
    handleView(row) {
      getAccount(row.id).then(response => {
        this.form = response.data;
        const imgs = [];
        this.form.imgList.map(function (item) {
          imgs.push(item.url);
        });
        this.srcList = imgs;
        this.openView = true;
        this.title = "经营户详情";
      });
    },
    /** 叉车详情 **/
    handleForkliftView(row) {
      this.$router.push({name: 'forkliftView', params:{stationId:row.stationId,stationName:row.stationName,businessId:row.id,companyName:row.companyName}})
    },
    handleWorkerView(row) {
      this.$router.push({name: 'businessWorkerView', params:{stationId:row.stationId,stationName:row.stationName,businessId:row.id,companyName:row.companyName}})
    },
    handleEquipmentView(row) {
      this.$router.push({name: 'equipmentView', params:{stationId:row.stationId,stationName:row.stationName,businessId:row.id,companyName:row.companyName}})
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != undefined) {
            updateAccount(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          } else {
            addAccount(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除该经营户的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delAccount(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有经营户台账数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportAccount(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "经营户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      importTemplate().then(response => {
        this.download(response.msg);
      });
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    // 处理状态
    typeFormat(val) {
      if (val == '0')
        return  '有'
      if (val == '1')
        return  '无'
    },
    beforeImageUpload(file){
      const isLt2M = file.size / 1024 / 1024 < 10
      if (!isLt2M) {
        this.$message.error('上传图片大小不能超过 10MB!')
        return false
      }
    },
    exceedFile(files, fileList) {
      let msg = `最多只能上传${this.uploadImg.limit}个图片`;
      this.$message.warning(msg)
    },
    //图片上传
    handleRemove(file, fileList) {
      this.form.imgs.splice(this.form.imgs.indexOf(file.url),1);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handlePictureSuccess(response, file) {
      this.form.imgs.push(response.fileName);
    },
  }
};
</script>
<style scoped lang="scss">
  .img ul{
    padding: 0;
  }
  .img ul li{
    float:left;
    width:20%;
    list-style:none;
    width: 100px;
    margin-right: 2%;
  }
  .el-upload__tip{
    font-size: 14px;
  }
</style>
